<template>
	<view class="majorMsgPage">

		<!--专业页面 开启下拉刷新和无数据显示图片 1 :empty-view-style="{'margin-top':'-200rpx'}" -->
		<z-paging ref="pagingb" v-model="majorMsgData" @query="getAllMajorData" :loading-more-no-more-text="''"
			:show-loading-more-no-more-line="true" :fixed="false" :auto="false" :loading-more-enabled="true">

			<uni-list :border="false">
				<uni-list-item link showArrow :title="item.name" :note="item.eduLevelName?item.eduLevelName:''"
					v-for="item in majorMsgData" :key="item.code" @click="clickbackMajors(item.code)">
				</uni-list-item>
			</uni-list>

		</z-paging>
		<loading v-show="loadshow"></loading>
	</view>
</template>

<script>
	export default {
		props: {
			datanumber: {
				type: Number,
				default: null
			},
			inputValue: {
				type: String,
				default: ''
			},
			isShowData: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				loadshow: false,
				majorMsgData: [],
				// majorMsgData: '',
				scrollTop: 0,
				searchData: '',
				positionBox: 1, //我是专业页面的状态 如果没有数据那么就为空

			}
		},
		methods: {
			getAllMajorData(page = 1, pageSize = 10) {
				if (this.isShowData == 2) {
					// uni.showLoading({
					// 	mask: true
					// })
				}
				pageSize = 50
				let data = {
					search: this.searchData,
					searchType: "major",
					page,
					pageSize
				}
				this.loadshow = true
				this.$request.searchType(data).then(res => {
					this.loadshow = false
					this.majorMsgData = res.data[0].data
					if (this.majorMsgData.length > 0) {
						this.positionBox = 1
						this.$emit("changeBoxIsShow", "majorMassage", 1)
					} else {
						this.positionBox = 2
						this.$emit("changeBoxIsShow", "majorMassage", 0)
					}

					this.$refs.pagingb.complete(res.data[0].data);
					uni.hideLoading()
				}).catch(err => {
					uni.hideLoading()
					uni.$emit('z-paging-error-emit')
				})
			},

			clickbackMajors(code) {
				// 根据code长度判断层级跳转页面
				if (code.length > 4) {
					uni.navigateTo({
						url: "/subpackages/subpackage1/pages/searchmajor/search-major-majordetail?code=" + code
					})
				} else {
					uni.navigateTo({
						url: '/subpackages/subpackage1/pages/searchmajor/see-major-class?code=' + code
					})
				}
			}
			// getMajorData() {
			// 	let data = {
			// 		search: this.searchData,
			// 		searchType: "major"
			// 	}
			// 	uni.showLoading({
			// 		mask: true
			// 	})
			// 	this.$request.searchType(data).then(res => {
			// 		this.majorMsgData = res.data[0].data
			// 		uni.hideLoading()
			// 		if (this.datanumber == 3) {
			// 			this.majorMsgData = this.majorMsgData.slice(0, 3)
			// 		}
			// 		if (!this.artcleMsgData) {
			// 			this.$emit("isLookMet", "majorMassage")
			// 		}
			// 	})
			// }

			// 点击列表进行一个跳转到对应页面
			,
			onClick(data) {
				uni.navigateTo({
					url: "/subpackages/subpackage1/pages/searchcollege/collegeDetails/news-details?data=" +
						encodeURIComponent(JSON
							.stringify(data))
				})
			},
			getMajorCellId(special_id) {
				uni.navigateTo({
					url: "/subpackages/subpackage1/pages/searchmajor/search-major-majordetail?special_id=" +
						special_id
				})
			}

		},
		watch: {
			inputValue: {
				handler() {
					this.searchData = this.inputValue
					this.getAllMajorData()
				},
				deep: true,
				immediate: true
			}

		},
		mounted() {
			this.searchData = this.inputValue
			// this.getAllMajorData()
		}
	}
</script>

<style lang="scss" scoped>
	.majorMsgPage {
		height: 100%;
	}

	.scroll-Y {
		height: 100%;
	}

	//定位图片盒子
	.positionBox {
		width: 300rpx;
		height: 300rpx;
		position: absolute;
		display: flex;
		flex-direction: column;
		top: calc(50% - 150rpx - 128rpx);
		left: calc(50% - 120rpx);

		image {
			width: 100%;
			height: 80%;
		}

		text {
			width: 100%;
			text-align: center;
		}
	}
</style>